package leader.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import leader.service.DirectTreatiseService;
import teacher.bean.Flow;
import teacher.bean.Project;
import teacher.bean.Treatise;
import teacher.service.flow;
import teacher.service.treatise;

public class DirectTreatiseReturnAction {
	private Treatise treatise;

	public Treatise getTreatise() {
		return treatise;
	}

	public void setTreatise(Treatise treatise) {
		this.treatise = treatise;
	}
	public String execute() {
		System.out.println(treatise.getTreId());
		treatise.setState(1);
		DirectTreatiseService TS = new DirectTreatiseService();
		TS.updateTreatiseState(treatise);
//		流程管理开始
		Treatise a=new Treatise();
		a=new treatise().selectTreatiseById(this.getTreatise().getTreId());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Flow f=new Flow();
		f.setFruitId(a.getTreId());
		f.setFruitKind(2);
		f.setDirDo(1);
		f.setDirTime(df.format(new Date()));
		f.setSubDo(2);
		f.setSubTime(df.format(new Date()));
		f.setTeaDo(2);
		f.setTeaTime(df.format(new Date()));
//		流程管理结束
		if(new flow().insertFlow(f)){
			return "success";
		}else{
			return "success";
		}
	}
}
